package com.zwh.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.util.Date;

public class SysLog {

    // 日志类型（access：接入日志；update：修改日志；select：查询日志；loginLogout：登录登出；）
    public static final String TYPE_ACCESS = "access";
    public static final String TYPE_UPDATE = "update";
    public static final String TYPE_SELECT = "select";
    public static final String TYPE_LOGIN_LOGOUT = "loginLogout";

    private static final long serialVersionUID = 1L;

    @TableId
    private String id;
    private String logType;			// 日志类型
    private String logTitle;		// 日志标题
    private String requestUri;		// 请求URI
    private String requestMethod;	// 操作方式
    private String requestParams;	// 操作提交的数据
    private String bizKey;			// 业务主键
    private String bizType;			// 业务类型
    private String remoteAddr;		// 操作IP地址
    private String serverAddr;		// 请求服务器地址
    private String isException;		// 是否有异常
    private String exceptionInfo;	// 异常信息
    private String userAgent;		// 用户代理
    private String deviceName;		// 设备名称/操作系统
    private String browserName;		// 浏览器名称
    private Long executeTime;		// 执行时间

    private String createBy;			// 业务类型
    private Date createDate;			// 创建时间
    private String updateBy;		// 操作IP地址
    private Date updateDate;			// 创建时间
    /**
     * 删除标志
     */
    @TableLogic
    private String deleteStatus;

    public SysLog() {
        this(null);
    }

    public SysLog(String id){
        this.setId(id);
    }

    @NotBlank(message="日志类型不能为空")
    @Length(min=0, max=1, message="日志类型长度不能超过 1 个字符")
    public String getLogType() {
        return logType;
    }

    public void setLogType(String logType) {
        this.logType = logType;
    }

    @NotBlank(message="日志标题不能为空")
    @Length(min=0, max=500, message="日志标题长度不能超过 500 个字符")
    public String getLogTitle() {
        return logTitle;
    }

    public void setLogTitle(String logTitle) {
        this.logTitle = logTitle;
    }

    @Length(min=0, max=500, message="请求URI长度不能超过 500 个字符")
    public String getRequestUri() {
        return requestUri;
    }

    public void setRequestUri(String requestUri) {
        this.requestUri = requestUri;
    }

    @Length(min=0, max=10, message="操作方式长度不能超过 10 个字符")
    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRequestParams() {
        return requestParams;
    }

    public void setRequestParams(String requestParams) {
        this.requestParams = requestParams;
    }

    @Length(min=0, max=64, message="业务主键长度不能超过 64 个字符")
    public String getBizKey() {
        return bizKey;
    }

    public void setBizKey(String bizKey) {
        this.bizKey = bizKey;
    }

    @Length(min=0, max=64, message="业务类型长度不能超过 64 个字符")
    public String getBizType() {
        return bizType;
    }

    public void setBizType(String bizType) {
        this.bizType = bizType;
    }

    @NotBlank(message="操作IP地址不能为空")
    @Length(min=0, max=255, message="操作IP地址长度不能超过 255 个字符")
    public String getRemoteAddr() {
        return remoteAddr;
    }

    public void setRemoteAddr(String remoteAddr) {
        this.remoteAddr = remoteAddr;
    }

    @NotBlank(message="请求服务器地址不能为空")
    @Length(min=0, max=255, message="请求服务器地址长度不能超过 255 个字符")
    public String getServerAddr() {
        return serverAddr;
    }

    public void setServerAddr(String serverAddr) {
        this.serverAddr = serverAddr;
    }

    public String getIsException() {
        return isException;
    }

    public void setIsException(String isException) {
        this.isException = isException;
    }

    public String getExceptionInfo() {
        return exceptionInfo;
    }

    public void setExceptionInfo(String exceptionInfo) {
        this.exceptionInfo = exceptionInfo;
    }

    @Length(min=0, max=500, message="用户代理长度不能超过 500 个字符")
    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    @Length(min=0, max=100, message="设备名称/操作系统长度不能超过 100 个字符")
    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    @Length(min=0, max=100, message="浏览器名称长度不能超过 100 个字符")
    public String getBrowserName() {
        return browserName;
    }

    public void setBrowserName(String browserName) {
        this.browserName = browserName;
    }

    public Long getExecuteTime() {
        return executeTime;
    }

    public void setExecuteTime(Long executeTime) {
        this.executeTime = executeTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String getDeleteStatus() {
        return deleteStatus;
    }

    public void setDeleteStatus(String deleteStatus) {
        this.deleteStatus = deleteStatus;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

}
